<%--
  Created by IntelliJ IDEA.
  User: lvjx
  Date: 2016/12/22
  Time: 14:04
  Desc: 
--%>
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta http-equiv="Pragma" content="no-cache">
    <meta http-equiv="Cache-Control" content="no-cache">
    <meta http-equiv="Expires" content="0">
    <title>吉车惠后台管理系统</title>
    <link href="${ctx}/assets/css/login.css" type="text/css" rel="stylesheet">
    <script type="text/javascript" src="${ctx}/assets/js/jquery/jquery-1.8.3.min.js"></script>
    <script type="text/javascript" src="${ctx}/assets/js/jquery/jquery.form.js"></script>
    <script type="text/javascript" src="${ctx}/assets/js/easyui/easyuiFormTools.js"></script>
</head>
<body>

<div class="login">
    <div class="message" style="font-size:24px;font-weight: bold;">车行天下-管理登录</div>
    <div id="darkbannerwrap"></div>
    <div id="errormsg" style="color:red;font-size:16px;padding-bottom:10px;display: none;"></div>
    <form id="form1" name="form1" method="post">
        <div>
            <input id="account" name="account" placeholder="请输入账号" value="" required type="text">
            <hr class="hr15">
        </div>
        <div>
            <input id="passwd" name="password" placeholder="请输入密码" value="" required type="password">
            <hr class="hr15">
        </div>
        <div>
            <input id="randCode" name="randCode" placeholder="验证码" required type="text" style="width:160px;">
            <img id="code" src="${ctx }/kaptcha" width="150" height="47" style="float: right"/>
        </div>
        <div>
            <p class="clearfix" style="margin-top:5px;"><a href="javascript:void(0)" onclick="refreshCode();">看不清？换一个</a>&nbsp;&nbsp;按右图填写，不区分大小写</p>
        </div>
        <hr class="hr15">
        <hr class="hr15">
        <input id="login" name="login" value="登录" style="width:100%;" type="button">
        <hr class="hr20">
        帮助 <a onClick="alert('请联系管理员')">忘记密码</a>
    </form>


</div>

<div class="copyright">© 2016车行天下</div>

</body>
<script type="text/javascript">
    $(function(){
        $("#login").click(function(){
            login();
        })

        $(".login").keydown(function(e){
            if (e.keyCode == 13){
                login();
            }
        })
    });

    login = function (){
        var account = $("#account").val();
        var passwd = $("#passwd").val();
        var randCode = $("#randCode").val();

        if(account == ""){
            $("#errormsg").html("登录账号不能为空！");
            jQuery('#errormsg').fadeIn();
            return ;
        }else if(passwd == ""){
            $("#errormsg").html("登录密码不能为空！");
            jQuery('#errormsg').fadeIn();
            return ;
        }
        else if(randCode == ""){
            $("#errormsg").html("验证码不能为空！");
            jQuery('#errormsg').fadeIn();
            return ;
        }

        $("#login").val("正在登录...");

        $.post('${ctx}/login', $("#form1").formSerialize(), function(json) {
            if(json.errcode =="0"){
                $("#errormsg").hide();
                self.location="${ctx}/mainframe/mf?r="+Math.random();
                return;
            }else if(json.errcode =="995"){
                $("#errormsg").html("登录帐户不存在或密码不正确！");
                jQuery('#errormsg').fadeIn();
            }else if(json.errcode =="994"){
                $("#errormsg").html("登录帐号已锁定，请联系统管理员！");
                jQuery('#errormsg').fadeIn();
            }else if(json.errcode =="993"){
                $("#errormsg").html("验证码不正确！");
                jQuery('#errormsg').fadeIn();
            }
            $("#login").val("登录");
        }, "JSON");

    }

    refreshCode = function(){
        $("#code").attr("src","${ctx }/kaptcha?r="+Math.random());
    };
</script>
</html>
